package com.cltech.entity.sys;

import com.cltech.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Administrator on 2018/9/5.
 */
@Getter
@Setter
@Entity
public class SysRole extends BaseEntity {
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id;
    @Column(unique = true)
    private String roleCode;
    private String name;
    private String description;
    @JsonIgnore
    @ManyToMany(cascade = CascadeType.REFRESH, mappedBy="roles", fetch = FetchType.LAZY)
    private Set<SysUser> users = new HashSet<>();
    @JsonIgnore
    @ManyToMany(cascade = CascadeType.REFRESH, mappedBy="roles", fetch = FetchType.LAZY)
    private Set<SysPermission> permissions = new HashSet<>();
}
